/*
 * Copyright (c) 2023 vitasystems GmbH
 *
 * This file is part of project EHRbase Migration Tool
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ehrbase.migration.exporter.v0.jooq.pg.tables;

import java.util.UUID;
import java.util.function.Function;
import org.ehrbase.migration.exporter.v0.jooq.pg.Ehr;
import org.ehrbase.migration.exporter.v0.jooq.pg.tables.records.AdminGetLinkedContributionsRecord;
import org.jooq.Field;
import org.jooq.Function2;
import org.jooq.Name;
import org.jooq.Records;
import org.jooq.Row2;
import org.jooq.Schema;
import org.jooq.SelectField;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({"all", "unchecked", "rawtypes"})
public class AdminGetLinkedContributions extends TableImpl<AdminGetLinkedContributionsRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>ehr.admin_get_linked_contributions</code>
     */
    public static final AdminGetLinkedContributions ADMIN_GET_LINKED_CONTRIBUTIONS = new AdminGetLinkedContributions();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<AdminGetLinkedContributionsRecord> getRecordType() {
        return AdminGetLinkedContributionsRecord.class;
    }

    /**
     * The column <code>ehr.admin_get_linked_contributions.contribution</code>.
     */
    public final TableField<AdminGetLinkedContributionsRecord, UUID> CONTRIBUTION =
            createField(DSL.name("contribution"), SQLDataType.UUID, this, "");

    /**
     * The column <code>ehr.admin_get_linked_contributions.audit</code>.
     */
    public final TableField<AdminGetLinkedContributionsRecord, UUID> AUDIT =
            createField(DSL.name("audit"), SQLDataType.UUID, this, "");

    private AdminGetLinkedContributions(Name alias, Table<AdminGetLinkedContributionsRecord> aliased) {
        this(alias, aliased, new Field[] {DSL.val(null, SQLDataType.UUID)});
    }

    private AdminGetLinkedContributions(
            Name alias, Table<AdminGetLinkedContributionsRecord> aliased, Field<?>[] parameters) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.function());
    }

    /**
     * Create an aliased <code>ehr.admin_get_linked_contributions</code> table
     * reference
     */
    public AdminGetLinkedContributions(String alias) {
        this(DSL.name(alias), ADMIN_GET_LINKED_CONTRIBUTIONS);
    }

    /**
     * Create an aliased <code>ehr.admin_get_linked_contributions</code> table
     * reference
     */
    public AdminGetLinkedContributions(Name alias) {
        this(alias, ADMIN_GET_LINKED_CONTRIBUTIONS);
    }

    /**
     * Create a <code>ehr.admin_get_linked_contributions</code> table reference
     */
    public AdminGetLinkedContributions() {
        this(DSL.name("admin_get_linked_contributions"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : Ehr.EHR;
    }

    @Override
    public AdminGetLinkedContributions as(String alias) {
        return new AdminGetLinkedContributions(DSL.name(alias), this, parameters);
    }

    @Override
    public AdminGetLinkedContributions as(Name alias) {
        return new AdminGetLinkedContributions(alias, this, parameters);
    }

    @Override
    public AdminGetLinkedContributions as(Table<?> alias) {
        return new AdminGetLinkedContributions(alias.getQualifiedName(), this, parameters);
    }

    /**
     * Rename this table
     */
    @Override
    public AdminGetLinkedContributions rename(String name) {
        return new AdminGetLinkedContributions(DSL.name(name), null, parameters);
    }

    /**
     * Rename this table
     */
    @Override
    public AdminGetLinkedContributions rename(Name name) {
        return new AdminGetLinkedContributions(name, null, parameters);
    }

    /**
     * Rename this table
     */
    @Override
    public AdminGetLinkedContributions rename(Table<?> name) {
        return new AdminGetLinkedContributions(name.getQualifiedName(), null, parameters);
    }

    // -------------------------------------------------------------------------
    // Row2 type methods
    // -------------------------------------------------------------------------

    @Override
    public Row2<UUID, UUID> fieldsRow() {
        return (Row2) super.fieldsRow();
    }

    /**
     * Call this table-valued function
     */
    public AdminGetLinkedContributions call(UUID ehrIdInput) {
        AdminGetLinkedContributions result = new AdminGetLinkedContributions(
                DSL.name("admin_get_linked_contributions"), null, new Field[] {DSL.val(ehrIdInput, SQLDataType.UUID)});

        return aliased() ? result.as(getUnqualifiedName()) : result;
    }

    /**
     * Call this table-valued function
     */
    public AdminGetLinkedContributions call(Field<UUID> ehrIdInput) {
        AdminGetLinkedContributions result = new AdminGetLinkedContributions(
                DSL.name("admin_get_linked_contributions"), null, new Field[] {ehrIdInput});

        return aliased() ? result.as(getUnqualifiedName()) : result;
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
     */
    public <U> SelectField<U> mapping(Function2<? super UUID, ? super UUID, ? extends U> from) {
        return convertFrom(Records.mapping(from));
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Class,
     * Function)}.
     */
    public <U> SelectField<U> mapping(Class<U> toType, Function2<? super UUID, ? super UUID, ? extends U> from) {
        return convertFrom(toType, Records.mapping(from));
    }
}
